<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@page import="java.util.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html lang="en">
<head>
<meta charset="utf-8" />
<title>个人信息</title>
<link rel="shortcut icon" type="image/png"
	HREF="img/favicons/favicon.png" />
<link rel="icon" type="image/png" HREF="img/favicons/favicon.png" />
<link rel="apple-touch-icon" HREF="img/favicons/apple.png" />
<!-- Main Stylesheet -->
<link rel="stylesheet" href="css/style.css" type="text/css" />
<!-- Your Custom Stylesheet -->
<link rel="stylesheet" href="css/custom.css" type="text/css" />

<link rel="stylesheet" type="text/css"
	href="css/jquery-ui-1.8.17.custom.css" />
<link rel="stylesheet" type="text/css" href="js/jqgrid/ui.jqgrid.css" />

<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>

<script type="text/javascript" src="js/jqgrid/grid.locale-en.js"></script>

<script type="text/javascript" src="js/jqgrid/jquery.jqGrid.src.js"></script>
<link type="text/css" href="css/jquery-ui-timepicker-addon.css"
	rel="stylesheet" />
<script type="text/javascript"
	src="js/timepack/jquery-ui-1.8.17.custom.min.js"></script>
<script type="text/javascript"
	src="js/timepack/jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript"
	src="js/timepack/jquery-ui-timepicker-zh-CN.js"></script>
<script type="text/javascript">
	jQuery(document).ready(function(){  
		$("#list1").jqGrid({
	        datatype: "local",
	        height: 400,
	        colNames:['','ID','昵称','房卡数'],
	        colModel:[
	        		  {name:'myradio',index:'myradio',sortable:false,align:"center",width:25,
			    			formatter:function radio(cellValue,option){
			   			  		return '<input type="radio" name="radio_'+option.gid+'"/>';
			   			  	}
			   		  },
	                  {name:'ID',index:'ID',sortable:false,key:true,align:"center"},
	                  {name:'NickName',index:'NickName',sortable:false,align:"center"},
	                  {name:'Gold',index:'Gold',sortable:false,align:"center"},
	              ],
            beforeSelectRow: function (rowid, e) {
                  var $radio = $(e.target).closest('tr').find('input[type="radio"]');
                  $radio.attr('checked', 'checked');
                  return true; // allow row selection
              },
	        viewrecords:true,
	        loadtext: '我正在吐血加载...', 
	        rowTotal:2000,
	        loadonce:true,
	        rowNum:50,
	        rowList:[10,50,100],
	        gridComplete: function() {
	        	$("#list1").jqGrid('setGridParam',{  
	      	    	datatype:'local'
	      	    });
	        },
	        autowidth: true, 
	        jsonReader:{
	                repeatitems : false
	        },
	        pager:"#pager1",
	        caption: "返回结果"
		}).navGrid('#pager1',{
				refresh : false,
				edit : false,
				add : false,
				del : false,
				search : true
		});
	});
	
	function find_exchange2() {
		var uid = $("#userid").val();
  		$("#list1").jqGrid('setGridParam',{  
  			url:'/GameServer/queryAction',
  	    	datatype:'json',
  	    	postData:{action:'userquery',uid:uid}
  	    }).trigger("reloadGrid"); //重新载入  
  	}
	
	function reloadGold(add) {
		var gold = parseInt($("#adminGold").val());
		$("#adminGold").val(gold-add);
  	}
	
	$(function () {
        $(".ui_timepicker").datetimepicker({
            showSecond: true,
            timeFormat: 'hh:mm:ss',
            stepHour: 1,
            stepMinute: 1,
            stepSecond: 1
        });
    });
    
	function delType1() {
		var selectedId = $("#list1").jqGrid("getGridParam", "selrow");
		$("#uu").val(selectedId);
		var $selRadio = $('input[name=radio_' + $("#list1")[0].id+ ']:radio:checked'), $tr;
		if ($selRadio.length > 0) {
			$tr = $selRadio.closest('tr');
			if ($tr.length > 0) {
				var rowData = $("#list1").jqGrid("getRowData", selectedId);
				var nameVar = rowData.ID;
				if (nameVar == null || nameVar == undefined || nameVar == ''){
					nameVar = $tr.attr("id");
					$("#uu").val(nameVar);
				}
				$("#modifyform")
				.dialog(
				{
					height : 300,
					width : 550,
					resizable : false,
					modal : true, //这里就是控制弹出为模态
					buttons : {
						"确定" : function() {
							//alert("在这里对数据进行修改！");
							/**
							 gameId = $("#mo_gameId").val();
							  var provinces = trim($("#mo_provinces").val());
							 **/
							var u = $("#u").val();
							if (u == null || u == undefined || u == ''){
								alert("请选择用户");
								return;
							}
							var params = {
								"action" : "sellerGold",
								"name" : nameVar,
								"gold" : u
							};
							$
									.ajax({
										url : "/GameServer/doAction",
										type : 'POST',
										data : params,
										dataType : "json",
										cache : false,
										success : function(data) {
											if (data.ok == 1
													|| data.ok == "1") {
												var addGold = parseInt($("#u").val());
												$("#u").val('');
												$("#e").val('');
												find_exchange2();
												reloadGold(addGold);
												alert(data.msg);
											}
										}
									});
							$(this).dialog("close");
						},
						"取消" : function() {
							$(this).dialog("close");
						}
					}
				});
			}
		} else {
			alert("请选择要发放的行");
		}
	}
</script>
</head>
<body>
	<!-- Header -->
	<%@include file="head.jsp" %>
	<div id="page">
		<!-- Wrapper -->
		<div class="wrapper">
				<div>
					<h4>
						现有房卡数：
						<input type="text" id="adminGold"  value="<%=admin.getGold() %>"/>
					</h4>
					<div class="box box-error">不要更改现有房卡数,改了也没有用</div>
					<hr />
					<p>
						<p>
							<label class="required">玩家id:</label>
							<input type="text" id="userid"  value="" name="userid" />
							<input type="button" class="btn btn-green big" value="查询" onclick="find_exchange2()" />
							<input type="button" class="btn btn-green big" value="充值" onclick="delType1()" />
							
							
						</p>
						&nbsp;
					</p>
					<div class="clear">&nbsp;</div>
					<table id="list1">
				        <tr>
				            <td />
				        </tr>
				    </table>
				    <div id="pager1">
				</div>
				
			<div id="modifyform" title="出售" style="display:none;">  <!-- 该Div的作用就是当点击jqGrid表格中的修改链接时弹出的dialog -->
	  				<p>对方id：<input type="text" id="uu" style="width:240px"/></p> 
	  				<p>出售数量：<input type="text" id="u" style="width:240px"/></p>
				</div>
			<div class="clear">&nbsp;</div>
		</div>
		</div>
	<footer id="bottom">
	<div class="wrapper-login">
		<p>
			Copyright &copy; 2013 <b><a HREF="http://www.lxkj.com"
				title="www.lxkj.com">www.lxkj.com</a></b> | Icons by <a
				HREF="http://www.lxkj.com">lxkj</a>
		</p>
	</div>
	</footer>
	<script type="text/javascript" SRC="js/administry.js"></script>
</body>
</html>